﻿using System;
using MakeItWeb.Framework;
using System.Web.UI.HtmlControls;

namespace AllNations.Controls
{
    public partial class LatestPhotoalbums : MakeItWebUserControl
    {
        private int _PageSize = 5;

        public int PageSize
        {
            get { return _PageSize; }
            set { _PageSize = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                rptPhotoalbum.DataSource = Photoalbum.ListLatestPhotoalbum(PageSize);
                rptPhotoalbum.DataBind();
            }
        }

        protected void lnkPhotoAlbum_Click(object sender, EventArgs e)
        {
        }

        protected void HeaderColspan_PreRender(object sender, EventArgs e)
        {
            HtmlTableCell cell = sender as HtmlTableCell;
            if (cell != null)
            {
                int iTruePageSize = Math.Max(rptPhotoalbum.Items.Count, PageSize);
                cell.Attributes["colspan"] = iTruePageSize.ToString();
            }
        }
    }
}